/**
 * 
 */
package br.srv.full.virtual.service.facade.users;

import java.util.List;

import br.srv.full.persistence.BeansManagerException;
import br.srv.full.serviceLocator.ServiceLocator;
import br.srv.full.serviceLocator.annotations.ServiceType;
import br.srv.full.virtual.bean.base.QueryID;
import br.srv.full.virtual.engine.users.FirstLoginException;
import br.srv.full.virtual.engine.users.PersonsManager;
import br.srv.full.virtual.engine.users.PersonsManagerException;
import br.srv.full.virtual.entities.auth.Login;
import br.srv.full.virtual.entities.auth.Person;
import br.srv.full.virtual.entities.auth.Role; 
import br.srv.full.virtual.entities.resume.UserLogin;

/**
 * @author Delfino
 * 
 */
public class PersonsManagerServiceFacade implements PersonsManager {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1304852679481213284L;
	
	
	private PersonsManager personsManager;
	{
		initEJB();
	}

	/**
	 * @param p_userLogin
	 * @param p_verifyPasswd
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#changePassword(br.srv.full.virtual.entities.resume.UserLogin,
	 *      java.lang.String)
	 */
	public UserLogin changePassword(UserLogin p_userLogin, String p_verifyPasswd) throws PersonsManagerException {
		return personsManager.changePassword(p_userLogin, p_verifyPasswd);
	}

	/**
	 * 
	 */
	private void initEJB() {
		personsManager = ServiceLocator.getService(PersonsManager.class, ServiceType.REMOTE);
	}

	/**
	 * @param p_userLogin
	 * @return
	 * @see br.srv.full.virtual.engine.users.PersonsManager#confirmRegistration(br.srv.full.virtual.entities.resume.UserLogin)
	 */
	public UserLogin confirmRegistration(UserLogin p_userLogin) {
		return personsManager.confirmRegistration(p_userLogin);
	}

	/**
	 * @param p_userLogin
	 * @return
	 * @see br.srv.full.virtual.engine.users.PersonsManager#consultIfEmailExist(br.srv.full.virtual.entities.resume.UserLogin)
	 */
	public boolean consultIfEmailExist(UserLogin p_userLogin) {
		return personsManager.consultIfEmailExist(p_userLogin);
	}

	/**
	 * @param p_userLogin
	 * @return
	 * @throws FirstLoginException
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#createFirstLogin(br.srv.full.virtual.entities.resume.UserLogin)
	 */
	public UserLogin createFirstLogin(UserLogin p_userLogin) throws FirstLoginException, PersonsManagerException {
		return personsManager.createFirstLogin(p_userLogin);
	}

	/**
	 * @param <bean>
	 * @param p_beanClass
	 * @return
	 * @see br.srv.full.virtual.engine.users.PersonsManager#find(java.lang.Class)
	 */
	public <bean extends Person> Object find(Class<bean> p_beanClass) {
		return personsManager.find(p_beanClass);
	}


	/**
	 * @param p_firstFaseCode
	 * @return
	 * @see br.srv.full.virtual.engine.users.PersonsManager#findUserLoginByUUID(java.lang.String)
	 */
	public List<UserLogin> findUserLoginByUUID(String p_firstFaseCode) {
		try {
			return personsManager.findUserLoginByUUID(p_firstFaseCode);
		} catch (BeansManagerException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	/**
	 * @return
	 * @see br.srv.full.virtual.engine.users.PersonsManager#getWorkerRoles()
	 */
	public List<Role> getWorkerRoles() {
		return personsManager.getWorkerRoles();
	}

	/**
	 * @param p_userLogin
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#increaseAccessCount(br.srv.full.virtual.entities.resume.UserLogin)
	 */
	public UserLogin increaseAccessCount(UserLogin p_userLogin) throws PersonsManagerException {
		return personsManager.increaseAccessCount(p_userLogin);
	}

	/**
	 * @param p_userLogin
	 * @param p_msg
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#logSiteUse(br.srv.full.virtual.entities.auth.Login,
	 *      java.lang.String)
	 */
	public void logSiteUse(Login p_userLogin, String p_msg) throws PersonsManagerException {
		personsManager.logSiteUse(p_userLogin, p_msg);
	}

	/**
	 * @param p_userLogin
	 * @param p_msg
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#logSiteUse(br.srv.full.virtual.entities.resume.UserLogin,
	 *      java.lang.String)
	 */
	public void logSiteUse(UserLogin p_userLogin, String p_msg) throws PersonsManagerException {
		personsManager.logSiteUse(p_userLogin, p_msg);
	}

	/**
	 * @param <bean>
	 * @param p_bean
	 * @param p_properties
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#persist(br.srv.full.virtual.entities.auth.Person,
	 *      java.lang.String[])
	 */
	public <bean extends Person> bean persist(bean p_bean, String... p_properties) throws PersonsManagerException {
		return personsManager.persist(p_bean, p_properties);
	}

	/**
	 * @param <bean>
	 * @param p_client
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#persist(br.srv.full.virtual.entities.auth.Person)
	 */
	public <bean extends Person> bean persist(bean p_client) throws PersonsManagerException {
		return personsManager.persist(p_client);
	}

	/**
	 * @param <bean>
	 * @param p_client
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#persistNew(br.srv.full.virtual.entities.auth.Person)
	 */
	public <bean extends Person> bean persistNew(bean p_client) throws PersonsManagerException {
		return personsManager.persistNew(p_client);
	}

	/**
	 * @param <bean>
	 * @param p_bean
	 * @param p_properties
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#refresh(br.srv.full.virtual.entities.auth.Person,
	 *      java.lang.String[])
	 */
	public <bean extends Person> bean refresh(bean p_bean, String... p_properties) throws PersonsManagerException {
		return personsManager.refresh(p_bean, p_properties);
	}

	/**
	 * @param p_userLogin
	 * @return
	 * @see br.srv.full.virtual.engine.users.PersonsManager#refreshUserLogin(br.srv.full.virtual.entities.resume.UserLogin)
	 */
	public UserLogin refreshUserLogin(UserLogin p_userLogin) {
		return personsManager.refreshUserLogin(p_userLogin);
	}
 

	/**
	 * @param <bean>
	 * @param p_bean
	 * @param p_properties
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#update(br.srv.full.virtual.entities.auth.Person,
	 *      java.lang.String[])
	 */
	public <bean extends Person> bean update(bean p_bean, String... p_properties) throws PersonsManagerException {
		return personsManager.update(p_bean, p_properties);
	}

	/**
	 * @param <bean>
	 * @param p_user
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#update(br.srv.full.virtual.entities.auth.Person)
	 */
	public <bean extends Person> bean update(bean p_user) throws PersonsManagerException {
		return personsManager.update(p_user);
	}

	/**
	 * @param p_userLogin
	 * @return
	 * @throws PersonsManagerException
	 * @see br.srv.full.virtual.engine.users.PersonsManager#update(br.srv.full.virtual.entities.resume.UserLogin)
	 */
	public UserLogin update(UserLogin p_userLogin) throws PersonsManagerException {
		return personsManager.update(p_userLogin);
	}

	/**
	 * @param p_string
	 * @param p_firstFaseCode
	 * @return
	 * @see br.srv.full.virtual.engine.users.PersonsManager#findUserLogin(br.srv.full.virtual.bean.base.QueryID, java.lang.String)
	 */
	public List<UserLogin> findUserLogin(QueryID p_string, String p_firstFaseCode) {
		return personsManager.findUserLogin(p_string, p_firstFaseCode);
	}
	
}
